package com.kangyi.admin.mapper;

import com.github.pagehelper.Page;
import com.kangyi.admin.annotation.AutoFill;
import com.kangyi.dto.GuestsStayingPageQueryDTO;
import com.kangyi.entity.GuestsStaying;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface GuestsStayingMapper {

    Page<GuestsStayingPageQueryVO> pageQuery(GuestsStayingPageQueryDTO guestsStayingPageQueryDTO);

    void deleteGuests(List<Integer> ids);

    GuestsStayingDetailVO detailGuest(Integer id);

    void editGuest(GuestsStaying guestsStaying);

    Page<ToExaminePageQueryVO> ToExaminePageQuery(GuestsStayingPageQueryDTO guestsStayingPageQueryDTO);


    @Select("select * from guests_staying where id = #{id}")
    GuestsStaying getById(Integer id);


    @Update("update guests_staying set status = #{status},update_user = #{updateUser}, update_time = #{updateTime} where id = #{id}")
    @AutoFill(value = OperationType.UPDATE)
    void examine(GuestsStaying build);

    ToExamineDetailVO detail(Integer id);

    @Select("select count(*) from guests_staying where nursing_home_id = #{nursingHomeId};")
    Long countByNursingHomeId(Integer nursingHomeId);

    @Delete("delete from guests_staying where user_id = #{userId};")
    void deleteByUserId(Integer userId);

    @Select("select * from guests_staying where user_id = #{id};")
    List<GuestsStaying> getByUserId(Integer id);


    @Select("select * from guests_staying where nursing_home_id = #{nursingHomeId};")
    List<GuestsStaying> getByNursingHomeId(Integer nursingHomeId);

    @Update("update guests_staying set nursing_home_id = null where id = #{id};")
    void updateNursingHomeIdIsNull(Integer id);
}
